public class LC1221E {
    public int balancedStringSplit(String s) {
        char[] ch=s.toCharArray();
        int count=0;
        int ans=0;
        int n=s.length();
        for (int i = 0; i < n; i++) {
            if (ch[i]=='R'){
                count+=1;
            }
            else
                count-=1;
            if (count==0){
                ans++;
            }
        }
        return ans;
    }
}
